package cn.itcast.hotel.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@Data
@NoArgsConstructor
public class HotelDoc {
    private Long id;
    private String name;//名称
    private String address;//地址
    private Integer price;//价格
    private Integer score;//评分
    private String brand;//品牌
    private String city;//城市
    private String starName;//星级
    private String business;//商圈
    private String location;//location = latitude(纬度),longitude(经度)
    private String pic;//图片
    private Object distance;
    private Boolean isAD;
    private List<String> suggestion;//做自动补全的内容

    public HotelDoc(Hotel hotel) {
        this.id = hotel.getId();
        this.name = hotel.getName();
        this.address = hotel.getAddress();
        this.price = hotel.getPrice();
        this.score = hotel.getScore();
        this.brand = hotel.getBrand();
        this.city = hotel.getCity();
        this.starName = hotel.getStarName();
        this.business = hotel.getBusiness();
        this.location = hotel.getLatitude() + ", " + hotel.getLongitude();
        this.pic = hotel.getPic();
        if(this.business.contains("/")){
            String [] arr = this.business.split("/");
            this.suggestion = new ArrayList<>();
            this.suggestion.add(this.brand);//品牌
            Collections.addAll(this.suggestion,arr);//商圈
        }else{
            this.suggestion = Arrays.asList(this.brand,this.business);//品牌和商圈：放入自动补全字段
        }
    }
}
